#ifndef __PLATE_SOLVER_H__
#define __PLATE_SOLVER_H__

#include <chrono>
#include <filesystem>

#include "astro_coordinates/ephemeris.h"
#include "cam_tele.h"
#include "file_manager/file_manager.h"

#include <opencv2/opencv.hpp>

class PlateSolving {
public:
    virtual int start(const cv::Mat& img, EquatorialCoordinates& eqCoord) = 0;
    virtual int stop() { return 0; }
};

class AstrometryNet : public PlateSolving {
private:
    FileManager file_manager_;
    std::filesystem::path fits_parent_path_ = "/tmp";
    int try_times_ = 0;
    
public:
    void setFitsParentPath(const std::filesystem::path& fits_parent_path) { 
        fits_parent_path_ = fits_parent_path; 
        try_times_ = 0;
    }
    int start(const cv::Mat& img, EquatorialCoordinates& eqCoord) override;
    int stop() override;
};

class PlateSolver {
private:
    cv::Size img_size_= cv::Size(1920, 1080);

    CamTele cam_tele_;

    PlateSolving* play_solving_ = nullptr;

private:
    void haCoordAtTime(const EquatorialCoordinates& starEqCoordJ2000, const std::chrono::system_clock::time_point& time_point, HourAngleCoordinates& starHaCoord);

public:
    PlateSolver(PlateSolving* play_solving) :  play_solving_(play_solving){}
    int start(EquatorialCoordinates& eqCoord, HourAngleCoordinates& haCoord);
    int stop();
};



#endif